﻿<%@ Import namespace="System"%>
<%@ Import namespace="System.Data"  %>
<%@ Page language="c#" Codebehind="SearchData.aspx.cs" AutoEventWireup="false" Inherits="UDS.SubModule.WorkAttendance.SearchData" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Language" content="zh-cn" />
<meta name="author" content="Herry" />
<meta name="Copyright" content="Copyright (c) 2009 himm.cn" />
<title>SearchData</title>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<script language="JavaScript" type="text/javascript" src="/Commons/DatePicker/WdatePicker.js"></script>
<link rel="stylesheet" type="text/css" href="/css/other.css" media="screen" />
<link rel="stylesheet" type="text/css" href="/css/table.css" />
<script language="JavaScript" src="/Css/meizzDate.js"></script>
		<script language="javascript">
		function fillstring(str)
		{
			if(str.length==1)
			{
				str = "0" + str; 
			}
			return(str);
		}
		function quickseldate(type)
		{
			var begintime,endtime;
			var oneminute = 60*1000;
			var onehour   = 60*oneminute;
			var oneday    = 24*onehour;
			var oneweek   = 7*oneday;
			
			var todayDate = new Date();
			var date = todayDate.getDate();
			var month= todayDate.getMonth() +1;
			var year= todayDate.getYear();
			var day = todayDate.getDay();
			if(navigator.appName == "Netscape")
			{
				year = 1900 + year;
			}

			//-->
						
			if(type=="day")
			{
				begintime = year.toString() + "-" + fillstring(month.toString()) + "-" + fillstring(date.toString());
				endtime = begintime;
			}
			else if(type=="week")
			{
				var daytoMon = day-1;
				if(day==0) 
					daytoMon = 6;
				
				todayDate.setTime(todayDate.getTime()-daytoMon*oneday);
				date = todayDate.getDate();
				month= todayDate.getMonth() +1;
				year= todayDate.getYear();
				day = todayDate.getDay();
				
				begintime = year.toString() + "-" + fillstring(month.toString()) + "-" + fillstring(date.toString());
				
				todayDate.setTime(todayDate.getTime()+6*oneday);
				
				date = todayDate.getDate();
				month= todayDate.getMonth() +1;
				year= todayDate.getYear();
				
				endtime = year.toString() + "-" + fillstring(month.toString()) + "-" + fillstring(date.toString());
			}
			else if(type=="month")
			{
				var dateto1 = date-1;
				
				todayDate.setTime(todayDate.getTime()-dateto1*oneday);
				date = todayDate.getDate();
				month= todayDate.getMonth() +1;
				year= todayDate.getYear();
				day = todayDate.getDay();
				
				begintime = year.toString() + "-" + fillstring(month.toString()) + "-" + fillstring(date.toString());
				
				todayDate.setMonth(month);
				todayDate.setTime(todayDate.getTime()-oneday);
				
				date = todayDate.getDate();
				month= todayDate.getMonth() +1;
				year= todayDate.getYear();
				
				endtime = year.toString() + "-" + fillstring(month.toString()) + "-" + fillstring(date.toString());

			}

			document.getElementById("txtbegintime").value = begintime;
			document.getElementById("txtendtime").value = endtime;
		
		}
		</script>
		<script language="C#" runat="server">
		 string  GetGridData(string staffid,int type)
		 {

			//type:0 正常 1：迟到 2：早退 3：未考勤 4：总考勤天数
			switch(type)
			{
				case 0:
					dvw.RowFilter = "OnDuty_Status = false and OffDuty_Status = false and staff_id="+staffid;
					break;
				case 1:
					dvw.RowFilter = "OnDuty_Status=true and staff_id="+staffid;
					break;
				case 2:
					dvw.RowFilter = "OffDuty_Status = true and staff_id="+staffid;
					break;
				case 3:
					dvw.RowFilter = "staff_id=" + staffid;
					return((dvw1.Count - dvw.Count).ToString());
					break;
				case 4:
					break;
			}
			return(dvw.Count.ToString());
		 
		 } 
		</script>
</head>
	<body>
		<form id="SearchData" method="post" runat="server">
		
<div class="m">
<p class="path"><a href="/SubModule/UnitiveDocument/">我的桌面</a> >> 考勤查询</p>
<div class="con">
<table bordercolor="#337FB2" border="1">
					<tr>
						<td style="width: 84px">查询时间</td>
						<td class="tl">开始时间：<asp:textbox id="txtbegintime" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" cssClass="Wdate" runat="server" ></asp:textbox><asp:requiredfieldvalidator id="RequiredFieldValidator1" runat="server" Display="None" ControlToValidate="txtbegintime" ErrorMessage="开始时间不能为空"></asp:requiredfieldvalidator> 结束时间：<asp:textbox id="txtendtime" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" cssClass="Wdate" runat="server" ></asp:textbox><asp:requiredfieldvalidator id="RequiredFieldValidator2" runat="server" Display="None" ControlToValidate="txtendtime" ErrorMessage="结束不能为空"></asp:requiredfieldvalidator> <asp:comparevalidator id="cvdate" runat="server" Display="None" ControlToValidate="txtendtime" ErrorMessage="结束时间应该大于开始时间" Operator="GreaterThanEqual" ControlToCompare="txtbegintime"></asp:comparevalidator> <asp:radiobutton id="rbtnthisweek" onclick="quickseldate('week');" runat="server" Text="本周" GroupName="quickdate"></asp:radiobutton><asp:radiobutton id="rbtnthismonth" onclick="quickseldate('month');" runat="server" Text="本月" GroupName="quickdate"></asp:radiobutton></td>
					</tr>
					<tr>
						<td>查找范围</td>
						<td class="tl"><asp:dropdownlist id="ddlsearchbound" runat="server" Width="300px" AutoPostBack="True">
								<asp:ListItem Value="0" Selected="True">公司</asp:ListItem>
								<asp:ListItem Value="1">职位</asp:ListItem>
								<asp:ListItem Value="2">个人</asp:ListItem>
							</asp:dropdownlist></td>
					</tr>
					<tr>
						<td>请 选 择</td>
						<td class="tl"><asp:listbox id="lbstaffs" runat="server" CssClass="inputcss" Width="150px" SelectionMode="Multiple" Height="141px" Visible="False"></asp:listbox><asp:dropdownlist id="ddldepartments" runat="server" Width="150px" Visible="False"></asp:dropdownlist></td>
					</tr>
					<tr>
						<td></td>
						<td class="tl"><asp:validationsummary id="vs1" runat="server"></asp:validationsummary></td>
					</tr>
					<tr>
						<td colSpan="2"><asp:button id="btnsearch" runat="server" CssClass="buttoncss" Text=" 查  询 "></asp:button></td>
					</tr>
				</table>
                <asp:datagrid id="AttendanceGrid" runat="server" Width="100%" CellPadding="3" BorderWidth="1px" BorderColor="#337FB2" DataKeyField="staff_id" EnableViewState="False" AutoGenerateColumns="False">
								<HeaderStyle  BackColor="#E8F4FF"></HeaderStyle>
								<Columns>
									<asp:BoundColumn DataField="realname" HeaderText="姓名">
										<ItemStyle ></ItemStyle>
										<FooterStyle ></FooterStyle>
									</asp:BoundColumn>
									<asp:TemplateColumn HeaderText="正常天数">
										<ItemTemplate>
											<asp:HyperLink Text ='<%# GetGridData(((DataRowView)Container.DataItem)["Staff_ID"].ToString(),0)%>' NavigateUrl='<%# "tmpStaffData.aspx?staffid="+((DataRowView)Container.DataItem)["Staff_ID"].ToString()+"&begintime="+txtbegintime.Text+"&endtime="+txtendtime.Text+"&type=1"%>' Target=_blank Runat=server>
											</asp:HyperLink>
										</ItemTemplate>
									</asp:TemplateColumn>
									<asp:TemplateColumn HeaderText="迟到天数">
										<ItemTemplate>
											<asp:HyperLink Text ='<%# GetGridData(((DataRowView)Container.DataItem)["Staff_ID"].ToString(),1)%>' NavigateUrl='<%# "tmpStaffData.aspx?staffid="+((DataRowView)Container.DataItem)["Staff_ID"].ToString()+"&begintime="+txtbegintime.Text+"&endtime="+txtendtime.Text+"&type=2"%>' Target=_blank Runat=server>
											</asp:HyperLink>
										</ItemTemplate>
									</asp:TemplateColumn>
									<asp:TemplateColumn HeaderText="早退天数">
										<ItemTemplate>
											<asp:HyperLink Text ='<%# GetGridData(((DataRowView)Container.DataItem)["Staff_ID"].ToString(),2)%>' NavigateUrl='<%# "tmpStaffData.aspx?staffid="+((DataRowView)Container.DataItem)["Staff_ID"].ToString()+"&begintime="+txtbegintime.Text+"&endtime="+txtendtime.Text+"&type=3"%>' Target=_blank Runat=server>
											</asp:HyperLink>
										</ItemTemplate>
									</asp:TemplateColumn>
									<asp:TemplateColumn HeaderText="未考勤天数">
										<ItemTemplate>
											<asp:HyperLink Text ='<%# GetGridData(((DataRowView)Container.DataItem)["Staff_ID"].ToString(),3)%>' NavigateUrl='<%# "tmpStaffData.aspx?staffid="+((DataRowView)Container.DataItem)["Staff_ID"].ToString()+"&begintime="+txtbegintime.Text+"&endtime="+txtendtime.Text+"&type=4"%>' Target=_blank Runat=server>
											</asp:HyperLink>
										</ItemTemplate>
									</asp:TemplateColumn>
									<asp:TemplateColumn HeaderText="总考勤天数">
										<ItemTemplate>
											<asp:HyperLink Text ='<%# GetGridData(((DataRowView)Container.DataItem)["Staff_ID"].ToString(),4)%>' NavigateUrl='<%# "tmpStaffData.aspx?staffid="+((DataRowView)Container.DataItem)["Staff_ID"].ToString()+"&begintime="+txtbegintime.Text+"&endtime="+txtendtime.Text+"&type=5"%>' Target=_blank Runat=server ID="Hyperlink1" NAME="Hyperlink1">
											</asp:HyperLink>
										</ItemTemplate>
									</asp:TemplateColumn>
								</Columns>
							</asp:datagrid>
                            <p><input class="buttoncss" id="btn_Report" type="button" value="打印报表" style="display:none" runat="server"></p>
  </div>
</div>
		</form>
</body>
</html>
